﻿/*
	Copyright © Bogdan Kobets 2011
	http://ElasticLogic.com
*/

using System;

namespace ElasticLogic.TagsMarker.Filter
{

	public abstract class FilterRule : ICloneable
	{
		public FilterMode Mode { get; private set; }

		public FilterRule Owner { get; set; }

		public bool HasOwner
		{
			get { return (Owner != null); }
		}

		internal bool? Satisfy { get; set; }

		public abstract string Expression { get; }

		public FilterRule(FilterMode mode)
		{
			this.Mode = mode;
			this.Satisfy = null;
		}

		public override string ToString()
		{
			return Expression;
		}

		internal abstract void ResetSatisfy();

		public abstract FilterRule CloneRule();

		public object Clone()
		{
			return CloneRule();
		}

		#region Operators overloading

		public static AND operator &(FilterRule left, FilterRule right)
		{
			return new AND(left, right);
		}

		public static OR operator |(FilterRule left, FilterRule right)
		{
			return new OR(left, right);
		}

		public static NOT operator !(FilterRule rule)
		{
			return new NOT(rule);
		}

		#endregion Operators overloading

	}

}
